<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('福利开启列表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: bootstrap-editable-css"/>
</head>
<style>
    .btns{
        float: right;
        margin-left: 195px;
    }

</style>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>代码：</p>
                            <input type="text" name="badge"/>
                        </li>
                        <li>
                            <p>姓名：</p>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">

            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:welfareopen:edit">
                <i class="fa fa-edit"></i> 修改
            </a>

            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:benefitbase:export">
                <i class="fa fa-download"></i> 导出
            </a>
            <div class="btn-group-sm btns">
                <a class="btn btn-primary multiple disabled" onclick="exhibition()">
                    <i class="fa fa-edit"></i> 展示
                </a>
                <a class="btn btn-success" onclick="procedureRegister('cSP_BenefitCheck')">
                    <i class="fa fa-plus"></i> 确认检查
                </a>
                <a class="btn btn-danger" onclick="procedureRegister('cSP_BenefitCancel')">
                    <i class="fa fa-remove"></i> 取消确认
                </a>
                <a class="btn btn-warning" onclick="procedureRegister('cSP_BenefitStart')">
                    <i class="fa fa-download"></i> 福利处理
                </a>
            </div>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: hr-help-js"/>

<script th:inline="javascript">
    var prefix = ctx + "welfare/welfareOpen";
    var benefitCitys = [];

    function procedureRegister(procedure) {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length == 0) {
            $.modal.alertWarning("请选择数据!");
            return;
        }
        var allId = "";
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","

            }
        }
        $.ajax({
            async: false,
            url: ctx + "welfare/welfareOpen/procedureRegister",
            data: {"ids":allId , "procedure" : procedure},
            type: "post",
            dataType: "text",
            success: function (data) {
                if (data != "") {
                    $.modal.alertWarning(data);
                } else {
                    $.modal.alertSuccess('确认检查成功');
                }
                $.table.refresh();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });


    }
    $(function () {
        getBenefitCitys();
        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + "/list",
            height: $(window).height() - 120,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "福利开启",
            columns: [{
                checkbox: true
            },
                {
                    field: 'badge',
                    title: '工号'
                },
                {
                    field: 'name',
                    title: '姓名'
                },
                {
                    field: 'compName',
                    title: '公司名称'
                },
                {
                    field: 'depName',
                    title: '部门名称'
                },
                {
                    field: 'jobName',
                    title: '工作岗位'
                },
                {
                    field: 'joinDate',
                    title: '入职时间'
                },
                {
                    field: 'empStatus',
                    title: '员工状态'
                },
                {
                    field: 'jobStatus',
                    title: '在岗状态'
                },
                {
                    field: 'benefitCity',
                    title: '社保缴纳地区'
                },
                {
                    field: 'beneAccount',
                    title: '社保账号'
                },
                {
                    field: 'accuCity',
                    title: '公积金缴纳地区'
                },
                {
                    field: 'accuAccount',
                    title: '公积金账号'
                },
                {
                    field: 'sbjs',
                    title: '社保基数'
                },
                {
                    field: 'gjjjs',
                    title: '公积金基数'
                },
                {
                    field: 'effectdate',
                    title: '生效日期'
                },
                {
                    field: 'initialized',
                    title: '？确认',
                    formatter: function (value, row, index) {
                        if(row.initialized==1){
                            return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
                        }else{
                             return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
                        }
                    }
                },
                {
                    field: 'initializedbyName',
                    title: '确认人'
                },
                {
                    field: 'initializedTime',
                    title: '确认时间'
                }]
        };


        $.table.init(options);
    });

    function getBenefitCitys() {
        $.ajax({
            async: false,
            url: ctx + "welfare/region/welfareRegionConfig/findAll",
            data: {},
            type: "post",
            dataType: "json",
            success: function (data) {
                for (var i = 0; i < data.length; i++) {
                    benefitCitys.push({value: data[i].id, text: data[i].title});
                }

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });

    }
</script>
</body>
</html>